﻿using Basic.FormGatewaryModular.Interface;
using Basic.FormRemoteModel.QueryGroup.Model;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Model;

namespace Basic.FormGatewaryModular.Api
{
    [ApiRouteName("/form/query/table/group/{name}")]
    internal class PhyQueryGroupApi : ApiController
    {
        private readonly IPhyQueryGroupService _Service;

        public PhyQueryGroupApi ( IPhyQueryGroupService service )
        {
            this._Service = service;
        }

        public long Add ( QueryGroupAdd data )
        {
            return this._Service.Add(data);
        }

        public void Delete ( [NumValidate("form.query.group.id.error", 1)] long id )
        {
            this._Service.Delete(id);
        }

        public QueryGroupDto Get ( [NumValidate("form.query.group.id.error", 1)] long id )
        {
            return this._Service.Get(id);
        }

        public bool Set ( LongParam<QueryGroupSet> set )
        {
            return this._Service.Set(set.Id, set.Value);
        }
    }
}
